package com.saifan.wyy_ov.ui.property;

import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;


import com.saifan.wyy_ov.R;
import com.saifan.wyy_ov.ui.view.BaseActivity;
import com.saifan.wyy_ov.ui.view.PagerSlidingTabStrip;
import com.saifan.wyy_ov.utils.DensityUtil;

import java.util.ArrayList;
import java.util.List;


/**
 * @version V1.0.0
 * @author: lomasky
 * @date: 2015-5-21 10:18:38
 * @descrption 进度查询
 */

public class ProgressQueryActivity extends BaseActivity {
    private Toolbar toolbar;
    private PagerSlidingTabStrip tabs;
    private ViewPager pager;
    private List<Fragment> list;
    private final String[] TITLES = {"报事报修", "投诉建议"};
    private int index=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView();

    }

    public void setContentView() {
        setContentView(R.layout.activity_progress_query);
        this.toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
        pager = (ViewPager) findViewById(R.id.pager);
        list = new ArrayList<>();
        RepairProgressFragment repairProgressFragment = new RepairProgressFragment();
        ComplainProgressFragment complainProgressFragment = new ComplainProgressFragment();
        list.add(repairProgressFragment);
        list.add(complainProgressFragment);

        pager.setAdapter(new MyAdapter(getSupportFragmentManager(), TITLES));
        pager.setOffscreenPageLimit(list.size());
        tabs.setTextColor(Color.parseColor("#A5FAFAFA"));
        tabs.setViewPager(pager);
        tabs.setTextSize(DensityUtil.dip2px(getApplicationContext(), 16));
        tabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                index = arg0;

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {

            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
            }
        });

    }




    public class MyAdapter extends FragmentStatePagerAdapter {
        String[] _titles;

        public MyAdapter(FragmentManager fm, String[] titles) {
            super(fm);
            _titles = titles;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return _titles[position];
        }

        @Override
        public int getCount() {
            return _titles.length;
        }

        @Override
        public Fragment getItem(int position) {
            return list.get(position);
        }

    }

}
